<?php
/**
 * admin service file Created by PhpStorm.
 * User: yang
 * Date: 2020/06/11
 */

namespace App\Http\Controllers\Web;

use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
use App\Http\Service\Web\UserService;

class UserController extends Controller
{
    /**
     * 用户主页
     * @param Request $request
     * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
     */
    public function home(Request $request)
    {
        $data = $request->all();

        $result = UserService::home($data);

        return view('Web.user.home', $result);
    }

    /**
     * 个人中心
     * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
     */
    public function index()
    {
        $result = UserService::index();
        return view('Web.user.index', $result);
    }

    /**
     * 获取个人信息
     * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
     */
    public function set()
    {
        $data = UserService::getUser();

        return view('Web.user.set', $data);
    }

    /**
     * 个人设置
     * @param Request $request
     * @return mixed
     */
    public function setIng(Request $request)
    {
        $post_data = $request->except(['_token', 'file']);
        $user = web_user_info();
        $post_data['id'] = $user['id'];

        return UserService::setIng($post_data);
    }

    /**
     * 个人消息
     */
    public function message()
    {
        return view('Web.user.message');
    }
}